import { multiply } from '@/utils/number'
import dayjs from 'dayjs'

export const clientColumn = [
  {
    prop: 'name',
    label: '客户名称'
  },
  {
    prop: 'mobile',
    label: '电话'
  },
  {
    prop: 'classNames',
    label: '班级'
  },
  {
    prop: 'childName',
    label: '宝宝姓名'
  },
  {
    prop: 'birthday',
    label: '宝宝生日',
    render: (row) => dayjs(row.birthday).format('YYYY/MM/DD')
  },
  {
    prop: 'month',
    label: '宝宝月龄'
  },
  {
    prop: 'relationship',
    label: '关系'
  }
]

export const seachConfigClient = (classes) => {
  return [
    {
      key: 'classId',
      label: '班级',
      type: 'select',
      fieldProps: {
        options: classes,
        props: { value: 'id', label: 'name' }
      }
    },
    {
      key: 'name',
      label: '学生姓名'
    }
  ]
}

export const columnProjects = (id) => {
  return [
    {
      prop: 'sort',
      label: '序号'
    },
    {
      prop: 'name',
      label: '收费项目',
      canEdit: !id
    },
    {
      prop: 'price',
      label: '单价',
      type: 'number',
      canEdit: !id,
      width: '140'
    },
    {
      prop: 'number',
      canEdit: true,
      required: true,
      type: 'number',
      label: '数量',
      width: '140'
    },
    {
      prop: 'amount',
      label: '金额',
      render: (row) => multiply(row.price, row.number)
    },
    {
      prop: 'remark',
      canEdit: true,
      required: true,
      label: '项目说明',
      width: '140'
    },
    {
      prop: 'action',
      label: '操作'
    }
  ]
}
